//
//  LDMyResumeBaseCellInAll.swift
//  DingDongZP
//
//  Created by LeMac on 16/12/27.
//  Copyright © 2016年 51ledian.com. All rights reserved.
//

import UIKit

enum LDMyResumeBaseCellInAllType {
    
    case Defalut
    case Edit
}
class LDMyResumeBaseCellInAll: UITableViewCell {

    
   
    //富文本 宽度
    let textViewWidth:CGFloat = LDFrame.ScreenWidth - 45
    
    var isHiddenEditBtn:Bool = true {
        didSet{
            editBtn?.hidden = isHiddenEditBtn
        }
    }
    
    internal(set) var bgView:UIView?
    private var titleLab:UILabel?
    var editBtn:UIButton?
    
    var tapClosure:((cell:LDMyResumeBaseCellInAll)->())?
    
    var model:DDMyResumeModel? {
        
        didSet {
            
            if model == nil { return }
            updateView()
        }
    }
    
    internal var title:String? {
        
        didSet{
            titleLab?.text = title
        }
    }
    
    lazy var noticeLab:UILabel = {
        
        let lab = UILabel.setDetailsLab("语音简历未录入", fontSize: 14, titleColor: LDFontColor.LightGray, Alignment: .Left)
        return lab
    }()
    
    /** 更新 */
    func updateView() {
        
    }
    
    //高度
    func getCellHeight(model:DDMyResumeModel) -> CGFloat {
        
        return 0
    }
    //点击按钮
    func tapEditBtn(colsure:((LDMyResumeBaseCellInAll)->Void)?) {
        
        tapClosure = colsure
    }
    
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        
        contentView.backgroundColor = LDGolbalColor.BgGoundGray
        selectionStyle = .None
        titleLab = UILabel.setDetailsLab("标题", fontSize: 16, titleColor: LDFontColor.BlackLight, Alignment: .Left)
        bgView = UIView()
        bgView?.backgroundColor = LDGolbalColor.White
        
        
        editBtn = UIButton()//setDetailsBtn("编辑", picName: nil, btnBackColor: LDGolbalColor.White, titleColor: LDGolbalColor.GreenAssist)
        editBtn?.setTitle("编辑", forState: .Normal)
        editBtn?.setTitleColor(LDGolbalColor.GreenAssist, forState: .Normal)
        editBtn?.layer.borderWidth = 1
        editBtn?.layer.borderColor = LDGolbalColor.GreenAssist.CGColor
        editBtn?.layer.cornerRadius = 9
        editBtn?.titleLabel?.font = LDFont.Font12

        editBtn?.bk_whenTapped({ [weak self] in
            
            if self?.tapClosure != nil {
                
                self?.tapClosure!(cell: self!)
            }
        })
        editBtn?.hidden = isHiddenEditBtn
        
        addSubview(titleLab!)
        addSubview(bgView!)
        bgView!.addSubview(editBtn!)
        
        titleLab?.snp_makeConstraints(closure: { (make) in
            
            make.top.right.equalTo(LDMargin_V*3)
            make.left.equalTo(LDMargin_V*3)
            make.height.equalTo(LDMargin_V*7)
        })
        
        bgView?.snp_makeConstraints(closure: { (make) in
            
            make.top.equalTo(titleLab!.snp_bottom)
            make.left.right.equalTo(0)
            make.bottom.equalTo(0)
        })
        
        editBtn?.snp_makeConstraints(closure: { (make) in
            
            make.top.equalTo(LDMargin_V*3)
            make.right.equalTo(-LDMargin_V*2)
            make.height.equalTo(18)
            make.width.equalTo(45)
        })
        
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
